package com.treasure.service.util;

import com.alibaba.fastjson.JSONObject;

/**
 * @Description: 
 * @version 1.0 
 * @author panxinwen 2018/11/2 16:39
 * @Copyright © 2015 | 武汉京航科技有限公司 Email:19919866605@163.com
 * */

public class ObjectUtil {
  public static <T> T converyToBean(Object obj, Class<T> c){
    T t = null;
    if (c.getSimpleName().equals("String")) {
      t = (T)obj;
    } else {
      if (TypeUtil.isJson(obj.toString())) {
        t = (T) JSONObject.parseObject(obj.toString(), c);
      } else if (TypeUtil.isXML(obj.toString())) {
        t = (T) JAXBUtil.converyToBean(obj.toString(), c);
      }
    }
    return t;
  }
}
